package com.itheima.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.common.R;
import com.itheima.domain.Order;
import com.itheima.domain.vo.OrderVo;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;


    //提交订单
    @PostMapping("/submit")
    public R<String> submitOrder(@RequestHeader("AuthorizationUser") String token, @RequestBody Order order) {
        log.info("token={},前端提交的订单数据order={}", token, order);
        return orderService.clientSubmitOrder(token, order);
    }

    @GetMapping("/userPage")
    public R<Page<OrderVo>> ordersToPage(@RequestHeader("AuthorizationUser") String token, @RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize) {
        log.info("page={},pageSize={}", page, pageSize);
        return orderService.clientOrderPageSelect(token, page, pageSize);
    }




}
